// 写入Cookie
const set = (name, value, { maxAge, domain, path, secure } = {}) => {
    let cookieText = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
    if (typeof maxAge === "number") {
        cookieText += `; max-age=${maxAge}`;
    }
    if (domain) {
        cookieText += `; domain=${domain}`;
    }
    if (path) {
        cookieText += `; path=${path}`;
    }
    if (secure) {
        cookieText += `; secure`;
    }
    document.cookie = cookieText;
};
const get = (name) => {
    name = `${encodeURIComponent(name)}`;
    const cookies = document.cookie.split("; ");
    for (const item of cookies) {
        const [cookieName, cookieValue] = item.split("=");
        if (cookieName === name) {
            return decodeURIComponent(cookieValue);
        }
    }
    return;
};
// 根据name,domain,和path删除Cookie
const remove = (name, { domain, path } = {}) => {
    set(name, "", { domain, path, maxAge: -1 });
};
export {set, get, remove };